package cn.qin.Services;
import net.sf.json.JSONArray;

import org.json.JSONException;

import cn.qin.DAO.newsOperateDAO;
import cn.qin.DAO.impl.newsOperateDAOimpl;
import cn.qin.Models.NEWS;
import cn.qin.Models.admin;

public class newsServices {
		newsOperateDAO newsoperatedao = new newsOperateDAOimpl();
	
	public newsOperateDAO getNewsoperatedao() {
		return newsoperatedao;
	}
	public void setNewsoperatedao(newsOperateDAO newsoperatedao) {
		this.newsoperatedao = newsoperatedao;
	}
	public void saveNews(NEWS news){
		this.newsoperatedao.saveNews(news);
		
	}
	public JSONArray showNews(String c_id) throws JSONException{
		return newsoperatedao.showNews(c_id);	
	}
	
	public void delNews(int id){
		this.newsoperatedao.delNews(id);

	}
	public boolean login(admin admin){
		if(newsoperatedao.login(admin))
			return true;
		else 
			return false;
	}
	public JSONArray showOneNews(String id) {
		
		return newsoperatedao.showOneNews(id);

		
	}
	public JSONArray showNewsByCid(int count, String cid) throws JSONException {
		
			return newsoperatedao.showNewsByCid(count, cid);
	}
	public JSONArray showHot(){
		System.out.println(newsoperatedao.showHot());
		
		return newsoperatedao.showHot();
}
	public void modifyPassword(String password,String username){
		this.newsoperatedao.modifyPassword(password,username);
		
	}
	public void editNews(int id,String title,String c_id,String content,int hot,String imgurl){
		this.newsoperatedao.editNews(id, title, c_id, content,hot,imgurl);		
	}
}
